/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package questionbook.service;

import java.util.List;
import org.openrdf.model.URI;
import questionbook.exception.IndividualAlreadyExistsException;
import questionbook.model.Answer;
import questionbook.model.Category;
import questionbook.model.Person;
import questionbook.service.common.GenericService;

/**
 * This Service holds all Methods for all CRUD-Operations
 * that belong to the Person-Model
 *
 * @author stefanstift
 */
public interface PersonService extends GenericService{

    /**
     *
     * @return a Person Object with an generated URI, ready to use and to persist
     * @throws IndividualAlreadyExistsException
     */
    public Person getIdentifiedPerson() throws IndividualAlreadyExistsException;


    /**
     *
     * @return a List of all Users in the System
     */
    public List<Person> getAll();

    /**
     *
     * @param uri
     * @return the User with the specified URI
     */
    public Person get(URI uri);

    /**
     *
     * @param mail
     * @return the User with the specified Mail-Address
     */
    public Person getByMail(String mail);

    /**
     *
     * @param id
     * @return the User with the specified External Long Identifier
     */
    public Person getByExtLongId(Long id);

    /**
     *
     * @param id
     * @return  the User with the specified External String Identifier
     */
    public Person getByExtStringId(String id);

    /**
     * Checks if a User with the specified Mail-Address is already available in the Store
     *
     * @param mail
     * @return true if the Mail already exists, false if not
     */
    public boolean exists(String mail);

    /**
     * Loads the User with the specified Mail-Address and Password from the Store
     *
     * @param mbox
     * @param password
     * @return the User with the specified Mail-Address and Password
     */
    public Person authenticate(String mbox, String password);
    
    
    /**
     * Loads the UserClass for the specified User
     * 
     * @param p
     */
    public void loadUserClass(Person p);

    /**
     * Loads the Cardinality of the Charma-Defintions for a specified User and
     * Charma-Type
     *
     * @param p
     * @param charma
     * @return the numer of stored Charma-Definition for the specified Person and Charma-Type
     */
    public int getCardinality(Person p, URI charma);

    /**
     *
     * @param c
     * @return a List fo Users (max. size = 3) that have given good Answers in a specified Category
     */
    public List<Person> suggestUsers(Category c);

    /**
     * Persists the specified Person in the Store
     *
     * @param p
     */
    public void persist(Person p);

    /**
     * Persists the AnswerClass for specified Answer
     *
     * @param a
     */
    public void persistAnswerClass(Answer a);

    /**
     * Persists a Charma-Definition for the Creator of the specified Answer and
     * the Charma-Type
     *
     * @param a
     * @param charma
     */
    public void persistCharma(Answer a, URI charma);



    /**
     * Updates the Properties that have changed for the specified User
     * @param p
     */
    public void update(Person p);

    /**
     * Updatees the UserClass for the specified User
     * @param p
     */
    public void updateClassification(Person p);

    /**
     * Deletes the specified User from the Store
     *
     * @param p
     */
    public void delete(Person p);

    /**
     * Removes the AnswerClass for the specified Answer and the Person who
     * created it
     * @param a
     */
    public void removeAnswerClass(Answer a);

    /**
     * Removes the Charma-Definition for the specified Answer ant the Person
     * who created it
     * @param a
     */
    public void removeCharma(Answer a);

    /**
     * Removes the UserClass for the specified Person
     * @param p
     */
    public void removeUserClass(Person p);


}
